package domain;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.IOException;
import java.sql.Connection;
import java.util.Properties;

public class Druiddb {
    private static Properties p=new Properties();
    public static DataSource ds=null;
    static {
        try {
            p.load(Thread.currentThread().getContextClassLoader()
                    .getResourceAsStream("Druiddb.properties"));
        ds= DruidDataSourceFactory.createDataSource(p);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void reSetUrl(String f){
        try {
            p.load(Druiddb.class.getClassLoader().getResourceAsStream(f));
            ds=DruidDataSourceFactory.createDataSource(p);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
